package com.inspector.app.ui.chat.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.inspector.app.R;

public class TaskStatusDialog extends Dialog {

    TextView contentTx, submit;
    Context context;

    public TaskStatusDialog(Context context) {
        super(context);
        this.context = context;
        initViews();
    }

    private void initViews() {
        // 设置窗口属性
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        // 加载布局
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.dialog_task_status, null);
        setContentView(view);
        findView(view);
        // 设置不可通过点击外部区域关闭
        setCancelable(false);
    }

    private void findView(View view) {
        submit = view.findViewById(R.id.submit);
        contentTx = view.findViewById(R.id.content);
    }

    public TaskStatusDialog setContent(String content) {
        contentTx.setText(content);
        return this;
    }

    public TaskStatusDialog setConfirmListener(View.OnClickListener listener) {
        submit.setOnClickListener(listener);
        return this;
    }

    @Override
    public void show() {
        super.show();
    }
}
